<!DOCTYPE html>
<#assign dicSelect=JspTaglibs["http://www.casic304.cn/dicSelect"] />
<#assign secSelect=JspTaglibs["http://www.casic304.cn/secSelect"] />
<#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />
<head>
  <meta charset="utf-8">
  <title>产品证书基本信息</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
  <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
  <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
  <link rel="stylesheet" href="${ctx}/qbdmsStatic/public/ztree/zTreeStyle.css"/>
  <script src="${ctx}/qbdmsStatic/public/ztree/jquery.min.js"></script>
  <script src="${ctx}/qbdmsStatic/public/ztree/jquery.ztree.all.min.js"></script>
  <script type="text/javascript">
    var __ctx = "${ctx}";
  </script>
  <style>
    .qbdms-TBinformation {
      margin-left: 0;
      font-size: 15px
    }

    .qbdms-TBinformationText {
      margin-left: 145px;
    }
  </style>
</head>

<body class="listBody">
<div class="qbdms-bodyDiv">
  <div class="qbdms-backDiv">
    <div class="layui-table-view-body" style="padding: 0 24px 24px;">
      <div class="qbdms-formTitle" style="border-bottom: 1px solid #E5F0FF">产品证书基本信息<i class="qbdms-returnOn closeWindow">返回</i></div>
      <form class="layui-form treeFormPreview" requrl="${ctx}/qbdms/wQbdProductCertificateInfo/get" lay-filter="wQbdProductCertificateInfoDataForm">
        <div class="layui-hide">
          <input type="text" name="id" placeholder="请输入" autocomplete="off" class="layui-input " maxlength="50">
          <input name="filldeptid" value="${filldeptid}" style="display: none"/>
          <input name="filldept" value="${filldept}" style="display: none"/>
          <input name="fillmanaccount" value="${fillmanaccount}" style="display: none"/>
          <input name="fillman" value="${fillman}" style="display: none"/>
          <input name="filldate" value="${filldate}" style="display: none"/>
        </div>
        <@fillDept.dept id="tbxx"/>
        <div class="layui-row">
          <div style="width: 45%">
            <label class="layui-form-label qbdms-label" title="密级">密级<span
                style="color: red;">*</span></label>
            <div class="layui-input-block qbdms-input">
              <@secSelect.sec_select required=true data_src=1 name="secret"/>
          </div>
          </div>
          <div style="width: 45%">
            <label class="layui-form-label qbdms-label" title="编号">编号<span style="color: red;">*</span></label>
            <div class="layui-input-block qbdms-input">
              <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput"
                     name="serialNumber" value="${num}" lay-verify="required" lay-reqtext="编号是必填项" maxlength="50" readonly>
            </div>
            <input type="hidden" name="serialNumberb" value="${numb}">
          </div>
          <div style="width: 45%">
            <label class="layui-form-label qbdms-label" title="型号代号">型号代号<span
                style="color: red;">*</span></label>
            <div class="layui-input-block qbdms-input">
              <select id="fModelsymbol" name="modelsymbol" class="layui-input filter-value"
                      lay-search="" lay-verify="required" lay-reqtext="型号代号是必填项" lay-filter="xh"
                      maxlength="50"></select>
            </div>
          </div>
            <div style="width: 45%">
              <label class="layui-form-label qbdms-label" title="产品名称">产品名称<span
                  style="color: red;">*</span></label>
              <div class="layui-input-block qbdms-input">
                <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput"
                       name="productName" maxlength="30" lay-reqtext="产品名称是必填项" lay-verify="required">
              </div>
            </div>
            <div style="width: 45%">
              <label class="layui-form-label qbdms-label" title="产品代号">产品代号<span
                  style="color: red;">*</span></label>
              <div class="layui-input-block qbdms-input">
                <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput"
                       name="productCode" maxlength="30" lay-reqtext="产品代号是必填项" lay-verify="required">
              </div>
            </div>
            <div style="width: 45%">
              <label class="layui-form-label qbdms-label" title="出厂编号">出厂编号<span
                  style="color: red;">*</span></label>
              <div class="layui-input-block qbdms-input">
                <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput"
                       name="factoryNumber" maxlength="32" lay-reqtext="出厂编号是必填项"
                       lay-verify="required">
              </div>
            </div>

            <div style="width: 45%">
              <label class="layui-form-label qbdms-label" title="出厂日期">出厂日期<span
                  style="color: red;">*</span></label>
              <div class="layui-input-block qbdms-input">
                <input type="text" placeholder="请选择" autocomplete="off"
                       class="layui-input dateTimeFiled input-right time-init" name="factoryTime"
                       maxlength="7" lay-reqtext="出厂日期是必填项" lay-verify="required" readonly>
              </div>
            </div>


            <div style="width: 45%">
              <label class="layui-form-label qbdms-label" title="检验员">检验员<span
                  style="color: red;">*</span></label>
              <button type="button" typeid="4" listAll="1" class="layui-btn qbdms-twoBtn selectorBtn" style="float: right">
                选择
              </button>
              <div class="layui-input-block qbdms-input qbdms-inputIsButton">
                <input type="text" name="inspectorsName" readonly="readonly" placeholder="请选择"
                       autocomplete="off" class="layui-input  selectorInput" lay-verify="required"
                       lay-reqtext="检验员是必填项"
                       maxlength="30" fieldname="inspectorsName">
                <input type="hidden" name="inspectorsId" placeholder="检验员ID"
                       autocomplete="off" class="layui-input  textInput getIds"
                       maxlength="100" fieldname="1734">

              </div>

            </div>


          <div style="width: 76%">
            <label class="layui-form-label qbdms-label" title="产品证明书上传">产品证明书上传</label>
            <div class="layui-input-block qbdms-input">
              <input type="button" class="layui-btn iconfont iconupload fileUpload qbdms-fileUp" value="产品证明书上传"/>
              <i class="qbdms-fileUpText">支持单个附件上传，附件格式：doc docx pdf，文件大小限制不超过100M</i>
              <input type="text" id="emergencyReleaseFormFile" class="uploadInput" name="emergencyReleaseFormFile" style="display: none">
              <div class="uploadFileList" fileUploadName="emergencyReleaseFormFile" style="padding-top: 9px;"></div>
            </div>
          </div>
        </div>
        <div class="layui-form-item btnformItem">
          <p style="text-align: left;padding-left: 246px">
                    <span id="hideAndShow" style="">
                        <a lay-submit lay-filter="wQbdProductCertificateInfo" class="layui-btn btn-n privateSubmit qbdms-oneBtn" requrl="${ctx}/qbdms/wQbdProductCertificateInfo/save">保存</a>
                    </span>
            <button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn layui-btn-sm qbdms-oneBtnLine closeWindow">取消</button>
          </p>
        </div>
      </form>
    </div>
  </div>
</div>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/json/comboselect.js" type="text/javascript"></script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>

<script>
  layui.config({
    base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'setter', 'layer', 'propsHandle', 'upload', 'common', 'laydate', 'jquery',
    'publicMethods', 'qbdmsForm'], function () {
    var $ = layui.jquery,
        laydate = layui.laydate,
        setter = layui.setter,  // 配置信息
        layer = layui.layer,
        common = layui.common,
        propsHandle = layui.propsHandle,
        upload = layui.upload,
        publicMethods = layui.publicMethods,
        formId = '' || '',
        defProps = {
          //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
          viewMould: 'moulds/', // 组件模块 存放文件 *****
          initCss: [
            'style/currencyCss'
          ],
          // formAreaInfo:'.formPreview',
          formAreaInfo: 'html',
          temDate: '.temDate',
          uploadFileBtn: '.uploadFileBtn',
          uploadImgBtn: '.uploadImgBtn',
          richTextArea: '.richTextArea',
          selectInput: '.selectInput',
          radioOptionCont: '.radioOptionCont',
          dataLexiTree: '.dataLexiTree',
          selectorBtn: '.selectorBtn',
        },
        temQuery = new propsHandle(),  // 实例化模板功能部分
        form = layui.qbdmsForm;
    // 初始化模板功能
    temQuery.initTem({
      selectorBtn: defProps.selectorBtn,
      selectorTemPath: setter.views + defProps.viewMould
    });
    var dateTimeFiledLen = $(".dateTimeFiled");
    for (var i = 0; i < dateTimeFiledLen.length; i++) {
      laydate.render({
        elem: dateTimeFiledLen[i] //指定元素
        , type: 'date'
        , trigger: 'click'
      });
    }
    var xhdh = eval('${wQbdXhdhs}'); //型号代号
    var initXHDH = function (optionObj, item) {
      optionObj.text = item.fModelcode;
      optionObj.value = item.fModelcode;
    };
    //- 添加表单验证规则 开始 ---------------------------------------------------------------------
    form.verify({
      length100: [/^.{0,100}$/, '输入字符数不能超过100'],
      length2000: [/^.{0,2000}$/, '输入字符数不能超过2000'],
      fileRequired: function (value, item) {
        value = $(item).siblings(".uploadInput").val()
        if (!new RegExp(/[\S]+/).test(value)) {
          return common.verifyTitleAdd(item) + "没有上传对应附件"
        }
      },
      money: function (value, item) {
        if (value && !new RegExp(
            /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/).test(value)) {
          return common.verifyTitleAdd(item) + '请输入数字且小数最多两位';
        }
      },
      integer: function (value, item) {
        if (value && !new RegExp(/^[+]{0,1}(\d+)$/).test(value)) {
          return common.verifyTitleAdd(item) + '请输入正整数';
        }
      }
    });

    common.initDicData("modelsymbol", xhdh, "", initXHDH);
    //关闭当前页面
    $("#closeWindow,.closeWindow").click(function () {
      window.location.href = '${ctx}/qbdms/wQbdProductCertificateInfo/view/list';
    });

    var runId = "${runId}";
    if (runId == null || runId == '') {
      $("#hideAndShow").show();
    }

    var common = layui.common;
    var index = parent.layer.getFrameIndex(window.name);
    common.updateForm({
      name: 'wQbdProductCertificateInfoDataForm',
      idValue: "${id}",
      primary: "id",
      beforeSubmitFun: function (data) {
        //- 附件密级不能高于表单密级 开始 ------------------------------------------------------
        var selectMaxVal = 0;
        var formSecretVal = $("[name='secret']").val();
        $(".fileSecLevel select").each(function () {
          selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
        });

        if (selectMaxVal > formSecretVal) {
          layer.msg('附件密级不能高于表单密级。', {icon: 5});
          return false;
        }
        //- 附件密级不能高于表单密级 结束 ------------------------------------------------------
        $(".uploadFileList").each(function (i, v) {
          common.constructFileStr(v)
        });
        var files=[];
        //整理上传附件的隐藏域，将提交的字符串转为json对象
        $(".uploadInput").each(function () {
          var uploadName = $(this).attr("name");
          if (!$(this).val()) {
            return;
          }
          data.field[uploadName] = eval($(this).val());
          files=files.concat(eval($(this).val()));
        });

        return common.setFileLevel(files);

      },
      getCallback: function (data) {
        $("#tbxx").html(
            "<span class='qbdms-TBinformation'>填报信息:</span><span class='qbdms-TBinformationText'>【"
            + data.data.filldept + " | " + data.data.fillman + " | " + data.data.filldate
            + "】</span>");
        $('.uploadFileList').each(function () {
          var fileUploadName = $(this).attr("fileUploadName");
          var jsonFile = data.data[fileUploadName];
          var files = eval(jsonFile);

          if (files) {
            for (var i = 0; i < files.length; i++) {
              var fileLevel = files[i].fileLevel;
              var fileLevelText = files[i].fileLevelText;
              var fileSec = '<div class="fileSecLevel layui-input-inline">'
                  + '<@secSelect.sec_select data_src=1 hasBlank=false/>'
                  + "</div>";
              var newStr = '<span class="file-id" style="margin-right: 20px;" fileId='
                  + files[i].fileId + ' fileLevelText="' + fileLevelText + '">'
                  + fileSec
                  + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont data-iconcommon_fujian" style="margin-right: 5px"></i>'
                  + files[i].fileName
                  + '</span><i class="iconfont data-iconcommon_close deleteFile" ></i></span>';
              $(this).append(newStr);
              $(this).find("select:last").val(fileLevel);
            }
          }
        });
      },
      updateCallback: function (data) {
        if (publicMethods._filterRecord(data)) {
          if ($(".privateSubmit")) {
            $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
          }
          layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'},
              function (index) {
                layer.close(index);

                window.location.href = '${ctx}/qbdms/wQbdProductCertificateInfo/view/list';
              });
        } else {
          layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'});
        }
        return false;
      }
    });
    var secSelect = '<@secSelect.sec_select data_src=1 hasBlank=false/>'
    common.uploadfun(".fileUpload", {
      acceptMime: 'application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document',
      exts: "doc|docx|pdf",
      secSelect: secSelect,
      isSub: false,
      upLoadSize:102400,
      upLoadNumber: 1,
      isMultiFile: false
    });

    publicMethods.bottomFixd()
    form.on('select', function (data) {
      publicMethods.bottomFixd()
    });
    form.render();
  });
</script>
</body>
</html>